<!-- 
* 结果页面详情页面
* 2019年5月16日17:06:10
* penglei
* -->
<template>
    <view class="content" style="background-image: url('../../static/img/bg3.png');">
		<scroll-view scroll-y="true" style="background-image: url('../../static/img/bg3.png');">
			<m-res :listData="listIt" @click="toPay"></m-res>
		</scroll-view>
		<cmd-bottom-nav @click="tapNav"  border-color="#BC1BBE" background-color="#BC1BBE" font-color="#fff" active-font-color="#fff" current="1"></cmd-bottom-nav>
    </view>
</template>

<script>
	import cmdBottomNav from "@/components/cmd-bottom-nav/cmd-bottom-nav.vue"
	import mbtn from "@/components/m-btn-type/m-btn.vue"
	import mBtnCs from '@/components/m-btn/m-btn-cs.vue'
	import mRes from '@/components/m-res/m-res.vue'
	import comm from '../../common/helpers.js'
    export default {
		components:{mbtn,cmdBottomNav,mBtnCs,mRes},
		data(){
			return{
				text:'请从1-10里选择一个数字',
				middleTitle:'过去的状况',
				middlePage:'3/3',
				middleTost:'摒弃杂念选择一个数字',
				cardList:[
					{
						defaultCard:'../../static/img/card_def_one.png',
						activeCard:'../../static/img/card_act_one.png'
					},{
						defaultCard:'../../static/img/card_def_two.png',
						activeCard:'../../static/img/card_act_two.png'
					},{
						defaultCard:'../../static/img/card_def_three.png',
						activeCard:'../../static/img/card_act_three.png'
					},{
						defaultCard:'../../static/img/card_def_four.png',
						activeCard:'../../static/img/card_act_four.png'
					},{
						defaultCard:'../../static/img/card_def_five.png',
						activeCard:'../../static/img/card_act_five.png'
					},{
						defaultCard:'../../static/img/card_def_six.png',
						activeCard:'../../static/img/card_act_six.png'
					},{
						defaultCard:'../../static/img/card_def_seven.png',
						activeCard:'../../static/img/card_act_seven.png'
					},{
						defaultCard:'../../static/img/card_def_et.png',
						activeCard:'../../static/img/card_act_et.png'
					},{
						defaultCard:'../../static/img/card_def_nin.png',
						activeCard:'../../static/img/card_act_nin.png'
					},{
						defaultCard:'../../static/img/card_def_ten.png',
						activeCard:'../../static/img/card_act_ten.png'
					}
				],
				//最后结果数组容器
				listIt:[],
				resList:[],
				resStr:'',
				statu:0,
				oid:'',
				uec:[]
			}
		},
        onLoad(event) {
			let that = this
			//过去、现在、未来数组容器
			let rel = Array();
			let where = []
			that.getOne(rel)
			that.resList = rel
			// 请求数据库
			//获取本地存储的用户openid
			that.oid  = uni.getStorageSync('openid')
			
        },
		methods:{
			getOne(_rel){
				let that = this
				let res = uni.getStorageSync('1')
				_rel = res
				where[0] = _rel
				where[1] = 2
				//调用方法
				that.getArr(where,"过去",1)
				that.getTow(_rel)
			},
			getTow(_rel){
				let that = this
				let res = uni.getStorageSync('2')
				_rel = res
				where[0] =_rel
				where[1] = 2
				//调用方法
				that.getArr(where,"现在",2)
				that.getThree(_rel)
			},
			getThree(_rel){
				let that = this
				let res = uni.getStorageSync('3')
				_rel = res
				console.log(_rel)
				where[0] = _rel
				where[1] = 2
				//调用方法
				that.getArr(where,"未来",3)
			},
			tapNav(e){
				let that = this
				let path = e.item.pagePath
				uni.switchTab({
					url:path,
					success: (res) => {
					},
					complete: (com) => {
					}
				})
			},
			getArr(where,title,group){
				let that = this
				let islock_two=0,islock_three=0
				let openid = uni.getStorageSync('openid')
				// 判断卡牌组
				/**
				 * islock_two：0 需要支付    1 不需要支付
				 * islock_three：0 需要支付    1 不需要支付
				 */
				if(group ==1){
						islock_two = 1
						islock_three = 1
				}
				// else if(group == 2){
				// 	// 查询现在数字的各个部分是否解锁
				// 	let parm = {
				// 		'mid':openid,
				// 		'r':'r2',
				// 		'val':where[0]
				// 	}
				// 	that.publicResult(comm.websiteUrl +'?s=v1/getueclist/','get',parm);
				// 	console.log(that.uec)
				// 	if(that.uec.code != 404){
				// 		islock_two = that.uec.data.r2_model1_pay
				// 		islock_three = that.uec.data.r2_model2_pay
				// 	}else{
				// 		islock_two = 1
				// 		islock_three = 0
				// 	}
				// }
				
				/**
				 * 进行数据请求，然后封装
				 */
				uni.request({
					url: comm.websiteUrl +'?s=v1/getgroup/',
					method: 'POST',
					data: {
						'gp':where[0],
						'tid':where[1],
						'mid':openid,
						'r':'r2',
						'val':where[0]
					},
					success: res => {
						console.log(res.data.data)
						if(group ==2){
							islock_two = 1
							islock_three = res.data.data.r2_model2_pay
						}else if(group == 3){
							islock_two = res.data.data.r3_model1_pay
							islock_three = res.data.data.r3_model2_pay
						}
						// 组装数据
						let arr = {
							'title':title + '',
							'content':res.data.data.content,
							'descript':res.data.data.descript,
							'numArr':res.data.data.narr,
							'ititle':title+'',
							'islock_two':islock_two,
							'islock_three':islock_three,
							'thumb':'../../static/img/qrcode.png',
						}
						// 装填数据
						this.listIt.push(arr)
					},
					fail: () => {},
					complete: () => {}
				});
			},
			/**
			 * @param {Object} _url
			 * @param {Object} _method
			 * @param {Object} _data
			 * @param {Object} _list  接收数据的数组
			 */
			publicResult:function(_url,_method,_data){
				let that = this
				uni.request({
					url: _url,
					method: _method,
					data:_data,
					success: res => {
						that.uec = res.data
						console.log("res.data----uec")
						console.log(that.uec)
					},
					fail: () => {},
					complete: () => {}
				});
			},
			toPay(e){
				// console.log(e)
				let that = this
				// console.log(e)
				//先生成订单，然后返回订单信息，如果订单创建成功，跳转支付页面
				// 生成订单
				uni.request({
					url: comm.websiteUrl+'?s=v1/generatorder/',
					method: 'POST',
					data: {
						//代表占卜中小分类，比如“爱情”
						'rule':e.rule,
						// 代表所属分类
						'id':e.id,
						// 代表用户openid
						'mid':that.oid,
						//代表数字组合
						'goods_id':e.goods_id
					},
					success: res => {
						// console.log(res)
						// console.log("------------订单创建------------")
						if(res.data.code == 200){
							uni.navigateTo({
								url:'/pages/user/user_pay?order_no='+res.data.data.order_no+'&mid='+that.oid+'&rule='+that.rule+'&mo='+that.mo+'&rmod='+that.rmod,
								success: (res) => {
								}
							})
						}else{
							uni.showModal({
								title:'警告',
								content:'订单创建失败!!!',
								showCancel:false,
								success:function(res){
								}
							})
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
    }
</script>

<style lang="scss">
	.content{
		padding: 0upx;
		height:100%;
		background-image: url('https://zhanbu.nomeis.cn/upload/page_resource/bg3.png');
		background-size: 100% 100%;
		
		scroll-view{
			height:91%;
			position:absolute;
			display:inline-block;
			background-image: url('https://zhanbu.nomeis.cn/upload/page_resource/bg3.png');
			background-size: 100% 100%;
		}
		
		._label_top{
			display:flex;
			width:100%;
			top:25upx;
			height:auto;
			position:relative;
			justify-content:center;

			._btn_top{
				height:185upx;
				width: 50%;
			}
			
			._lab_top{
				z-index:3;
				color:white;
				width:30%;
				text-align:center;
				justify-content:center;
				align-items:center;
				position:absolute;
				display:flex;
				margin:auto;
				height:100%;
			}
		}
		
		._bg_middle{
			width:100%;
			height:20%;
			position:absolute;
			z-index:7;
			margin:auto;
			justify-content:center;
			vertical-align:middle;
			align-items:center;
			display:flex;
			margin-top:125rpx;
			color: white;
			
			._middle_title{
				font-size:13pt;
				width:100%;
				position:absolute;
				margin-top:1rpx;
				text-align:center;
			}
			._middle_page{
				width:100%;
				position:absolute;
				font-size:9pt;
				margin-top:40rpx;
				text-align:center;
			}
			._middle_tost{
				width:100%;
				position:absolute;
				font-size:8pt;
				margin-top:80rpx;
				text-align:center;
				display:inline-block;
			}
			
			m-card{
				width:100%;
			}
		}
		
		._next{
			width:50%;
			margin:auto;
			margin-top:105%;
			position:relative;
			
			._tost{
				color:white;
				font-size:8pt;
				text-align:center;
				position:relative;
				display:flex;
				margin-top:25upx;
			}
		}
	}
</style>
